package edu.vt.ece.rt.dstm.contention;

import edu.vt.ece.rt.dstm.Context;


public class Polite extends AbstractContentionPolicy{

	/* Let smaller go if you are higher priority
	 * @see edu.vt.ece.rt.dstm.contention.AbstractContentionPolicy#resolve(edu.vt.ece.rt.dstm.Context, edu.vt.ece.rt.dstm.Context)
	 */
	@Override
	public int resolve(Context context1, Context context2) {
		if(context1.getContextId() > context2.getContextId())
			return -1;						//Priority queue will arrange as head least priority transaction first, so reversed
		else if (context1.getContextId() < context2.getContextId())
			return +1;
		else
			return 0;
	}

	@Override
	public void init(Context context) {}

	@Override
	public void open(Context context) {}
}
